#include "processbar.h"

#define FILE_SIZE 1024*1024*1024

void download()
{
    int total = FILE_SIZE;
    srand(time(NULL)^1023);
    while (total)
    {
        usleep(20000);
        int one = rand()%(2 * 1024 * 1024);
        total -= one;
        if (total < 0)
            total = 0;
        
        int download = FILE_SIZE - total;
        double rate = (download * 1.0 / (FILE_SIZE)) *100;
        process_fflush(rate);
    }
}
// make a test 
int main()
{
    download();
    return 0;
}
